#include<stdio.h>

void Swap(int* left, int* right) {
	int temp = *left;
	*left = *right;
	*right = temp;
	return;
}
void Back_Word(int* nums, int start, int end) {
	while (start < end) {
		Swap(&nums[start++], &nums[end--]);
	}
	return;
}

void Rotate(int* nums,int numSize, int k) {
	k %= numSize;
	//左旋 ：k  = numSize - k;--》转为右旋
	//右旋
	Back_Word(nums, 0, k - 1);
	Back_Word(nums, k, numSize - 1);
	Back_Word(nums, 0, numSize - 1);
	return;
}

void Print(int* nums, int size) {
	for (int i = 0; i < size; i++)
		printf("%d ", nums[i]);
	printf("\n");
	return;
}
int main() {
	int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
	int numSize = sizeof(arr) / sizeof(arr[0]);
	Print(arr, numSize);
	int k;
	printf("输入右旋个数>>");
	scanf("%d", &k);
	Rotate(arr, numSize, k);
	Print(arr, numSize);

}